package com.cskaoyan.config;


import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;


@Component
public class AnnoInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        
        
        List<String> userList = (List<String>) request.getServletContext().getAttribute("userList");
        if (userList == null) {
            // 增加在线状态表
            userList = new ArrayList<>();
            request.getServletContext().setAttribute("userList", userList);
        }
        return true;
    }
}
